/** \file    MotionParams.h
  * \brief   Defines parameters affecting restoration of motion from profiles.
  * \date    2003
  * \author  Fedor Chelnokov
  * \version $Header: /home/cscom1r4/cvsroot/cs/include/segm/MotionParams.h,v 1.2 2005/05/08 10:26:24 cscom1r4 Exp $
  */

#ifndef _MotionParams_h_
#define _MotionParams_h_

#include <read_enum.h>

enum MuSource {
	MU_USER,
	MU_FIRST_ITER,
	MU_EACH_ITER
};

enum TransformClass {
	TRANSFORM_AFFINE,
	TRANSFORM_QUADRATIC,
	TRANSFORM_TRANSLATION,
	TRANSFORM_RIGID,
	TRANSFORM_RIGID_ZOOM
};

const char * const TransformClassStrings[] = 
	{"affine", "affine" /*forbids quadratic*/, "translation", "rigid", "rigid+zoom", 0};

DEFINE_INLINE_ENUM_IO_OPERATORS(TransformClass, TransformClassStrings)


struct MotionParams {
	///The weight of the sum of neighbours' profiles under argmax. 
	///Used to obtain the initial approximation of displacements.
	float	tau;

	///The maximum number of iterations to be done in the solution optimization process.
	///If zero, the process ends up with the initial solution approximation, if -1 nothing is done at all.
	int		maxIterations;

	///Iterations stop as soon as the relative change in the optimized function falls below this value.
	float	minRelativeFimpr;

	///The value of the parameter mu (relating the effects of motion coherence and goodness of correlation) is ...
	MuSource muSource;

	///The explicitly set value of mu. Used in this capacity only when the 'source of mu' is set to 'user-defined'.
	///This dimensional coefficient relates the effects of displacement coherence and correlation in the optimized function.
	float	muValue;

	///The ratio of the correlation terms and the neighbour displacement coherency terms in the optimized function.
	///Used only if the 'source of mu' is not set to 'user-defined'.
	float	muProfileRatio;

	///Selects between a 6-parameter affine motion model and the 12-parameter quadratic model.
	TransformClass transformClass;

	///Sets the number of times the optimized segment motion is fit by the selected model
	///and the results used as a starting point for the next round of iterations.
	unsigned correctionLoops;

	///If this flag is set, the final segment motion is corrected to comply with selected model.
	bool	finalCorrection;

	bool operator == (const MotionParams & p) const
	{
		return tau == p.tau
			&& maxIterations == p.maxIterations
			&& minRelativeFimpr == p.minRelativeFimpr
			&& muSource == p.muSource
			&& muValue == p.muValue
			&& muProfileRatio == p.muProfileRatio
			&& transformClass == p.transformClass
			&& correctionLoops == p.correctionLoops
			&& finalCorrection == p.finalCorrection;
	}
	bool operator != (const MotionParams & p) const
		{ return !operator == (p); }
};

#endif //_MotionParams_h_
